package com.woniuxy.controller;

import com.woniuxy.Exception.serviceException;
import com.woniuxy.dao.DoctorDao;
import com.woniuxy.entity.Doctor;
import com.woniuxy.entity.Inspect;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.ResponseResult;
import com.woniuxy.service.InspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class InspectController {
    @Autowired
    InspectService inspectService;

    //路径变量参数
    //inspect/{pageIndex}/{pageSize}
    @PostMapping("/inspect/{pageIndex}/{pageSize}")
    public ResponseResult<PageBean<Inspect>> getAllInspects(@PathVariable("pageIndex") int pageIndex, @PathVariable("pageSize") int pageSize,
                                                    @RequestBody Inspect inspect) {
        ResponseResult<PageBean<Inspect>> resInspect;
        try {
            PageBean<Inspect> pageBean = inspectService.getAllInspectsPageByCondition(inspect, pageIndex, pageSize);
             resInspect = new ResponseResult<>(200, "ok", pageBean);
            return resInspect;
        } catch (serviceException e) {
            resInspect = new ResponseResult<>(500, e.getMessage(), null);
            return resInspect;
        }
    }
}
